<?php
/**
 * @file
 * Creates a page with sections using jQuery UI's 'Accordian' widget.
 *
 * Usage:
 *  - A page that wants to create a page with sections using jQuery UI's
 *    'Accordian' widget should include/require this file once and only once.
 *  - This page creates an entire HTML page (i.e. it starts with the '<html>'
 *    tag and ends with the '</html>' tag. Therefore, it should not be embedded
 *    withing another HTML page.
 *
 * Parameter(s):
 *  - $TITLE        : Title of the page.
 *  - $FILES_CSS    : Array of application specific CSS files to load.
 *  - $FILES_JS     : Array of application specific JavaScript files to load.
 *  - $PARAM_GET_JS : Flag 'GET' parameters should be stored in a JavaScript
 *                    variable. (See 'js_params_get.php'.)
 *  - $JS_INIT      : Initialization JavaScript. (Optional.)
 *  - $HEADER       : Page header. (Optional.)
 *  - $FOOTER       : Page footer. (Optional.)
 *  - $HEADING_PAGE : Page heading. (Optional.)
 *  - $HEADINGS     : Array of section headings.
 *  - $CONTENTS     : Array of section contents.
 *
 * Global variable(s) set:
 *  - None.
 *
 * Global variable(s) unset:
 *  - None.
 *
 * Exception(s):
 *  - None.
 *
 * This file includes/requires:
 *  - h_common.php
 *  - js_params_get.php (if '$PARAM_GET_JS' is 'true')
 *  - fb_iframe_resize_div.php (if '$IS_FACEBOOK' is 'true')
 *  - fb_js_feature_loader.php (if '$IS_FACEBOOK' is 'true')
 *  - fb_js_iframe_resize.js.php (if '$IS_FACEBOOK' is 'true')
 */

// header file(s) ==============================================================
require_once $PATH_COMMON . "php/h_common.php";


// implementation ==============================================================
$IS_FACEBOOK = true;  // TODO: De-couple from Facebook.
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><?php echo $TITLE ?></title>
    <link type="text/css" href="<?php echo CSS_JQUERY_UI ?>" rel="stylesheet" />
    <link type="text/css" href="<?php echo CSS_COMMON ?>" rel="stylesheet" />
    <link type="text/css" href="<?php echo CSS_JQUI ?>" rel="stylesheet" />
    <?php foreach ($FILES_CSS as $file_css) { ?>
    <link type="text/css" href="<?php echo $file_css ?>" rel="stylesheet" />
    <?php } ?>
    <script type="text/javascript" src="<?php echo JS_JQUERY ?>"></script>
    <script type="text/javascript" src="<?php echo JS_JQUERY_UI ?>"></script>
    <?php foreach ($FILES_JS as $file_js) { ?>
    <script type="text/javascript" src="<?php echo $file_js ?>"></script>
    <?php } ?>
    <?php if (true == $PARAM_GET_JS) { ?>
    <?php require_once $PATH_COMMON . "php/js_params_get.php"; ?>
    <?php } ?>
    <script type="text/javascript">
      // jquery initialization
      $(document).ready(function () {
        // Accordion
        $("#accordion").accordion({
          collapsible: true,
          header: "#accordion_header"
        });

        <?php
        if (isset($JS_INIT)) {
          // initialization javascript
          echo $JS_INIT;
        }
        ?>
      });
    </script>
  </head>
  <body>
    <?php if (isset($HEADER)) { include $HEADER; } ?>
    <?php if (isset($HEADING_PAGE)) { ?>
    <h2><?php echo $HEADING_PAGE ?></h2>
    <?php } ?>
    <div id="accordion">
      <?php foreach ($HEADINGS as $i => $heading) { ?>
      <div>
        <h3 id="accordion_header"><a href="#"><?php echo $heading?></a></h3>
        <div><?php echo $CONTENTS[$i]?></div>
      </div>
      <?php } ?>
    </div>
    <?php if (isset($FOOTER)) { include $FOOTER; } ?>
    <?php if (true == $IS_FACEBOOK) { ?>
    <?php require_once $PATH_COMMON . "php/fb_iframe_resize_div.php" ?>
    <?php require_once $PATH_COMMON . "php/fb_js_feature_loader.php" ?>
    <script type="text/javascript">
    <?php require $PATH_COMMON . "php/fb_js_iframe_resize.js.php" ?>
    </script>
    <?php } ?>
  </body>
</html>
